﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Web.UI.WebControls;
using Telerik.Web.UI;
using DotNetNuke.Entities.Modules;
using ilangl.DNNCLS.Components;

namespace ilangl.DNNCLS
{
	public partial class ProjectTree : DnnModuleBase	
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				BindTree(ctlProjects);
			}
		}

		protected void BindTree(DnnTreeView tree)
		{
			tree.Nodes.Clear();

			var rootNode = new RadTreeNode() { Text = LocalizeString("ProjectRootNode") };
			rootNode.Expanded = true;
			rootNode.AllowEdit = false;
			rootNode.EnableContextMenu = true;
			rootNode.ImageUrl = GetIcon(IconManager.ModuleIcon);
			tree.Nodes.Add(rootNode);

			rootNode.Nodes.Add(GetStateNode("ProjectStateArchived"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateCancelled"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateConfiguration"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateFinished"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateInProgress"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateReadyToStart"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateUnknown"));
			rootNode.Nodes.Add(GetStateNode("ProjectStateWaitingForQuota"));
			
		}

		protected RadTreeNode GetStateNode(String resourceKey)
		{
			var node = new RadTreeNode() { Text = LocalizeString(resourceKey) };
			node.Expanded = true;
			node.AllowEdit = false;
			node.EnableContextMenu = true;

			return node;
		}
	}
}